home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.ibm.xml.parser; import java.util.Enumeration; import org.w3c.dom.DOMException; import org.w3c.dom.DocumentFragment; import org.w3c.dom.EntityReference; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public abstract class Parent extends Child { static final long serialVersionUID = -5379012622242611200L; TXNodeList children = new TXNodeList(); public NodeList getChildNodes() { return this.children; } public boolean hasChildNodes() { return this.children.getLength() > 0; } public Enumeration elements() { return this.children.elements(); } public Child[] getChildrenArray() { Child[] var1 = new Child[this.children.getLength()]; this.children.nodes.copyInto(var1); return var1; } public Node getFirstChild() { return this.children.getLength() > 0 ? this.children.item(0) : null; } public Node getFirstWithoutReference() { Node var1; Node var2; for(var1 = this.getFirstChild(); var1 != null && var1.getNodeType() == 5; var1 = var2) { var2 = var1.getFirstChild(); if (var2 == null) { var1 = ((Child)var1).getNextWithoutReference(); break; } } return var1; } public Node getLastChild() { int var1 = this.children.getLength(); return var1 > 0 ? this.children.item(var1 - 1) : null; } public Node getLastWithoutReference() { Node var1; Node var2; for(var1 = this.getLastChild(); var1 != null && var1.getNodeType() == 5; var1 = var2) { var2 = var1.getLastChild(); if (var2 == null) { var1 = ((Child)var1).getPreviousWithoutReference(); break; } } return var1; } protected abstract void checkChildType(Node var1) throws DOMException; protected void realInsert(Node var1, int var2) throws DOMException { if (var1.getParentNode() != null) { var1.getParentNode().removeChild(var1); } this.checkChildType(var1); if (var1 == this) { throw new TXDOMException((short)3, "Can't have itself as child."); } else { TXDocument var3 = ((Child)this).getFactory(); if (var3 != null) { if (var3.isCheckOwnerDocument() && var3 != var1.getOwnerDocument()) { throw new TXDOMException((short)4, "Specified child was created from a different document. The parent is \"" + ((Child)this).getNodeName() + "\", the child is \"" + var1.getNodeName() + "\"."); } if (var3.isCheckNodeLoop()) { Object var4 = this; while((var4 = ((Node)var4).getParentNode()) != null) { if (var4 == var1) { throw new TXDOMException((short)3, "Can't have an ancestor as child"); } } } } this.children.insert(var2, var1); ((Child)var1).setParentNode(this); ((Child)this).clearDigest(); } } public synchronized void insert(Node var1, int var2) throws DOMException { if (!(var1 instanceof DocumentFragment)) { this.realInsert(var1, var2); } else { Node var3; while((var3 = var1.getLastChild()) != null) { var1.removeChild(var3); this.insert(var3, var2); } } } public synchronized Node insertBefore(Node var1, Node var2) throws DOMException { if (var2 == null) { this.insert(var1, this.children.getLength()); } else { int var3 = this.children.indexOf(var2); if (var3 < 0) { throw new TXDOMException((short)8, "com.ibm.xml.parser.Parent#insertBefore(): Node " + var2 + " is not found in the child list."); } this.insert(var1, var3); } return var1; } public synchronized Node insertAfter(Node var1, Node var2) throws DOMException { if (var2 == null) { this.insert(var1, 0); } else { this.insertBefore(var1, var2.getNextSibling()); } return var1; } public synchronized Node insertFirst(Node var1) { this.insert(var1, 0); return var1; } public synchronized Node insertLast(Node var1) { this.insert(var1, this.children.getLength()); return var1; } /** @deprecated */ public synchronized void addElement(Child var1) { if (var1 != null) { this.insert(var1, this.children.getLength()); } } public synchronized Node appendChild(Node var1) { if (var1 != null) { this.insert(var1, this.children.getLength()); } return var1; } public synchronized Node replaceChild(Node var1, Node var2) throws DOMException { int var3 = this.children.indexOf(var2); if (var3 < 0) { throw new TXDOMException((short)8, "com.ibm.xml.parser.Parent#replaceChild(): Node " + var2 + " is not found in the child list."); } else if (var1 == var2) { return var1; } else { if (var1.getParentNode() != null) { var1.getParentNode().removeChild(var1); } Child var4 = (Child)var1; this.children.replace(var3, var4); var4.setParentNode(this); ((Child)this).clearDigest(); return var2; } } public synchronized Node removeChild(Node var1) throws DOMException { int var2 = this.children.indexOf(var1); if (var2 < 0) { throw new TXDOMException((short)8, "com.ibm.xml.parser.Parent#removeChild(): Node " + var1 + " is not found in the child list."); } else { this.children.remove(var2); ((Child)this).clearDigest(); return var1; } } protected void processAfterRemove(Node var1) { short var2 = var1.getNodeType(); if (var2 == 1) { ((TXElement)var1).collectNamespaceAttributes(this); } else { if (var2 == 5) { ((GeneralReference)var1).collectNamespaceAttributes(this); } } } public void expandEntityReferences() { Node var1 = this.getFirstChild(); while(var1 != null) { if (var1 instanceof Parent) { ((Parent)var1).expandEntityReferences(); if (var1 instanceof EntityReference) { Node var2; while((var2 = var1.getLastChild()) != null) { var1.removeChild(var2); this.insertAfter(var2, var1); } var2 = var1.getNextSibling(); this.removeChild(var1); var1 = var2; continue; } } var1 = var1.getNextSibling(); } } public String getText() { int var1; if (this.children != null && (var1 = this.children.getLength()) != 0) { if (var1 == 1) { return ((Child)this.children.item(0)).getText(); } else { StringBuffer var2 = new StringBuffer(128); TXNodeList var3 = this.children; synchronized(var3){} try { for(int var5 = 0; var5 < var1; ++var5) { var2.append(((Child)this.children.item(var5)).getText()); } } catch (Throwable var7) { throw var7; } return var2.toString().intern(); } } else { return ""; } } }